package ch5.ext;

//抽象宠物，共性
public abstract class Pet {
	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}

	public int getLove() {
		return love;
	}

	public void setLove(int love) {
		this.love = love;
	}

	protected String name;
	private int health, love;
	private String type;// 品种

	public Pet() {
		System.out.println("无参的pet构造方法");
	}

	public Pet(String name, int health, int love, String type) {
		super();
		this.name = name;
		this.health = health;
		this.love = love;
		this.type = type;
	}

	protected void setType(String n) {
		this.type = n;
	}

	// public Pet(){}
	public void printInfo() {
		System.out.println("这个宠物品种是" + type + ",名字是" + name);
		System.out.println("健康程度" + health + ",可爱程度：" + love);
	}

	public void playWith() {
		System.out.println(name + "在陪主人玩耍");
	}

	public void run() {
		System.out.println("宠物" + name + "在跑。。。");
	}

	// 方法有，不知道怎么实现
	public abstract void shout();

	// public void shout() {
	// System.out.println("宠物" + name + "在叫。。。");
	// }

	public String getName() {
		return this.name;
	}

	public String getType() {
		return this.type;
	}

	@Override // 字符串的形式表示这个对象
	public String toString() {
		// System.out.println("调用了toString");
		return "[这是一个宠物，名字叫" + name + ",属于" + type + ",健康程度:" + health + ",可爱度：" + love + "]";
	}
}
